<!-- 管理员添加专业 -->
<template>
  <div class="assessment-edit-plan-container">
    <div class="my-form-container" style="margin:0;width:100%;height: 100%">
      <el-form
        :model="ruleForm"
        :rules="rules"
        ref="ruleForm"
        class=" demo-ruleForm"
      >
        <el-form-item class="my-form-item" prop="zymc">
          <div class="my-form-item-label">
            专业名称:
          </div>
          <el-input v-model="ruleForm.zymc" placeholder="请输入专业名称"></el-input>
          <el-form-item class="my-form-item" prop="zyjc">
            <div
              class="my-form-item-label"
            >
              专业简称:
            </div>
            <el-input v-model="ruleForm.zyjc" placeholder="请输入专业简称"></el-input>
          </el-form-item>
        </el-form-item>
           <el-form-item class="my-form-item" prop="cdyq">
          <div class="my-form-item-label">
            承担院区:
          </div>
          <!-- <el-input v-model="ruleForm.cdyq"></el-input> -->
          <el-select
              v-model="cdyq"
              style="margin-left: 40px; "
              placeholder="请选择"
            >
              <el-option
                v-for="item in cdyqList"
                :key="item.value"
                :label="item.deptName"
                :value="item.deptName"
              >
              </el-option>
            </el-select>
            <el-form-item class="my-form-item" prop="pycc">
            <div
              class="my-form-item-label"
              style="border-left: 1px solid rgba(0, 76, 167, 0.39);"
            >
              培养层次:
            </div>
            <el-select
              v-model="pycc"
              style="margin-left: 40px; "
              placeholder="请选择"
            >
              <el-option
                v-for="item in pyccList"
                :key="item.value"
                :label="item.dictValue"
                :value="item.id+','+item.dictValue"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-form-item>
        <el-form-item class="my-form-item" prop="yndm">
          <div class="my-form-item-label">
            院内代码:
          </div>
          <el-input v-model="ruleForm.yndm" placeholder="请输入院内代码"></el-input>
          <el-form-item class="my-form-item" prop="bzdm">
            <div
              class="my-form-item-label"
              style="border-left: 1px solid rgba(0, 76, 167, 0.39);"
            >
              标准代码:
            </div>
            <el-input v-model="ruleForm.bzdm" placeholder="请输入标准代码"></el-input>
          </el-form-item>
        </el-form-item>
        <el-form-item class="my-form-item" prop="ywmc">
          <div class="my-form-item-label">
            英文名称:
          </div>
          <el-input v-model="ruleForm.ywmc" placeholder="请输入英文名称"></el-input>

          <el-form-item class="my-form-item" prop="xkml">
            <div
              class="my-form-item-label"
              style="border-left: 1px solid rgba(0, 76, 167, 0.39);"
            >
              学科门类:
            </div>

            <el-select
              v-model="xkml"
              style="margin-left: 40px;"
              placeholder="请选择"
            >
              <el-option
                v-for="item in xkmlList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-form-item>
        <el-form-item class="my-form-item" prop="type">
          <div class="my-form-item-label">
            授权学位:
          </div>

          <el-checkbox-group
            style="width: 542px;margin-left: 40px;
            margin-top: 20px;display: flex;"
            v-model="sqxw"
         
            @change="handleCheckedCitiesChange"
          >
            <el-checkbox
              v-for="item in sqxwLists"
              :label="item"
              :key="item"
              style="display: block"
              >{{ item }}</el-checkbox
            >
          </el-checkbox-group>
          <el-form-item class="my-form-item" prop="bzxz">
            <div
              class="my-form-item-label"
              style="border-left: 1px solid rgba(0, 76, 167, 0.39);"
            >
              标准学制:
            </div>

            <el-select
              v-model="bzxz"
              style="margin-left: 40px;"
              placeholder="请选择"
            >
              <el-option
                v-for="item in bzxzList"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
        </el-form-item>
        <el-form-item class="my-form-item" prop="pzwh">
          <div class="my-form-item-label">
            批准文号:
          </div>
          <el-input v-model="ruleForm.pzwh" placeholder="请输入批准文号"></el-input>

          <el-form-item class="my-form-item" prop="jlny">
            <div
              class="my-form-item-label"
              style="border-left: 1px solid rgba(0, 76, 167, 0.39);"
            >
              建立年月:
            </div>
            <el-date-picker
              value-format="yyyy-MM-dd"
              v-model="ruleForm.jlny"
              style="margin-left: 40px;"
              type="date"
              placeholder="选择日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-form-item>
        <el-row class="my-form-item" style="height: 100px">
          <el-col :span="24">
            <div class="my-form-item-label">专业介绍</div>
            <el-input
              v-model="ruleForm.zyjs"
              placeholder="请输入专业介绍"
              class="zyjs"
              type="textarea"
            ></el-input>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div style="padding:30px;text-align:center;">
      <div class="button-group">
        <div class="" @click="submitForm('ruleForm')">保 存</div>
        <div class="" @click="resetForm">取 消</div>
      </div>
    </div>
      <!-- <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">
            专业名称<span style="color: #ff3819">*</span>
          </div>
          <el-input
            v-model="tablelist.zymc"
            placeholder="请输入名称（必填）"
          ></el-input>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">
            专业简称<span style="color: #ff3819">*</span>
          </div>
          <el-input
            v-model="tablelist.zyjc"
            placeholder="请输入简称（必填）"
          ></el-input>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="24">
          <div class="my-form-item-label">
            专业编号<span style="color: #ff3819">*</span>
          </div>
          <el-input v-model="tablelist.zybh" placeholder="请输入" style="margin-left:40px"></el-input>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">
            承担院区<span style="color: #ff3819">*</span>
          </div>
          <el-input v-model="tablelist.cdyx" placeholder="请输入"></el-input>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">
     <span style="color: #ff3819">*</span>
          </div>
          <el-input v-model="tablelist.pycc" placeholder="请输入"></el-input>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">
            院内代码<span style="color: #ff3819">*</span>
          </div>
          <el-input v-model="tablelist.yndm" placeholder="请输入"></el-input>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">标准代码</div>
          <el-input v-model="tablelist.bzdm" placeholder="请输入"></el-input>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">英文名称</div>
          <el-input v-model="tablelist.ywmc" placeholder="请输入"></el-input>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">
            学科门类<span style="color: #ff3819">*</span>
          </div>
          <div class="my-form-item-value">{{ tablelist.xkml }}</div>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">授权学位</div>
          <el-checkbox-group v-model="sqxw">
            <el-checkbox label="是"></el-checkbox>
            <el-checkbox label="否"></el-checkbox>
          </el-checkbox-group>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">
            标准学制<span style="color: #ff3819">*</span>
          </div>
          <el-input v-model="tablelist.bzxz" placeholder="请输入"></el-input>
        </el-col>
      </el-row>
      <el-row class="my-form-item">
        <el-col :span="12">
          <div class="my-form-item-label">批准文号</div>
          <el-input v-model="tablelist.pzwh" placeholder="请输入"></el-input>
        </el-col>
        <el-col :span="12">
          <div class="my-form-item-label">建立年月</div>
          <div
            class="block"
            style="
              width: 100%;
              margin: 0 auto;
              align-items: center;
              display: flex;
            "
          >
            <el-date-picker
              v-model="tablelist.jlny"
              type="month"
              placeholder=""
            >
            </el-date-picker>
          </div>
        </el-col>
      </el-row>
      <el-row class="my-form-item" style="height: 100px">
        <el-col :span="24">
          <div class="my-form-item-label">专业介绍</div>
          <el-input
            v-model="tablelist.zyjs"
            placeholder="请输入"
            class="zyjs"
          ></el-input>
        </el-col>
      </el-row> -->
    <!-- <div class="button-group">
      <div class="" @click="baoc('保存')">保存</div>
      <div class="" @click="qux('取消')">取消</div>
    </div> --> 
  </div>
</template>

<script>
import { tjzy, slePro,cdyqselect,pyccselect} from "@/api/professional/details";
const cityOptions = ["是", "否"];
export default {
  data() {
    return {
      sqxw: [],
       cdyq: "", 
      cdyqList:[], 
        pycc: "", 
        pyccList:[],
      bzxz: "",
      
      bzxzList: [
        {
          value: "01月",
          label: "01月"
        },
        {
          value: "02月",
          label: "02月"
        },
        {
          value: "03月",
          label: "03月"
        },
        {
          value: "04月",
          label: "04月"
        },
        {
          value: "05月",
          label: "05月"
        },
        {
          value: "06月",
          label: "06月"
        },
        {
          value: "07月",
          label: "07月"
        },
        {
          value: "08月",
          label: "08月"
        },
        {
          value: "09月",
          label: "09月"
        },
        {
          value: "10月",
          label: "10月"
        },
        {
          value: "10周",
          label: "10周"
        },
        {
          value: "一年",
          label: "一年"
        },
        {
          value: "两年半",
          label: "两年半"
        },
        {
          value: "三年",
          label: "三年"
        },
        {
          value: "四年",
          label: "四年"
        }
      ],
      xkml: "",
      xkmlList: [
        {
          value: "哲学",
          label: "哲学"
        },
        {
          value: "经济学",
          label: "经济学"
        },
        {
          value: "法学",
          label: "法学"
        },
        {
          value: "教育学",
          label: "教育学"
        },
        {
          value: "文学",
          label: "文学"
        },
        {
          value: "历史学",
          label: "历史学"
        },
        {
          value: "理学",
          label: "理学"
        },
        {
          value: "工学",
          label: "工学"
        },
        {
          value: "农学",
          label: "农学"
        },
        {
          value: "医学",
          label: "医学"
        },
        {
          value: "军事学",
          label: "军事学"
        },
        {
          value: "管理学",
          label: "管理学"
        }
      ],
      sqxwLists: cityOptions,
      showYprDialog: false,


      ruleForm: {
        zymc: "",
        zyjc: "",
        cdyq: "",
        pycc: "",
        yndm: "",
        bzdm: "",
        ywmc: "",
        pzwh: "",
        zyjs: "",
        jlny: ""
      },
      rules: {
        zymc: [{ required: true, message: "请输入专业名称", trigger: "blur" }],
        zyjc: [{ required: true, message: "请输入专业简称", trigger: "blur" }],
        yndm: [{ required: true, message: "请输入院内代码", trigger: "blur" }],
        bzdm: [
          { required: true, message: "请输入标准代码", trigger: "blur" },
        ],
        // date1: [
        //   {
        //     type: "date",
        //     required: true,
        //     message: "请选择日期",
        //     trigger: "change"
        //   }
        // ],
        // date2: [
        //   {
        //     type: "date",
        //     required: true,
        //     message: "请选择时间",
        //     trigger: "change"
        //   }
        // ],
        // type: [
        //   {
        //     type: "array",
        //     required: true,
        //     message: "请至少选择一个活动性质",
        //     trigger: "change"
        //   }
        // ],
        // resource: [
        //   { required: true, message: "请选择活动资源", trigger: "change" }
        // ],
        // desc: [{
        //    required: true, message: "请填写活动形式", trigger: "blur"
        //    }]
      }
    };
  },
  mounted() {
    this.cdyqselect();
    this.pyccselect();
    this.selectPro();
    console.log(this.$route.query.rowins, "000000");
  },
   
  methods: {
      cdyqselect() {
     let parentId = "0";
      return new Promise(() => {
        cdyqselect(parentId).then(res => {
          this.cdyqList = res.data.data
         console.log(res.data.data,"cdyqselect")
        });
      });
      
    
    },

  pyccselect(){
     let code = "pylevel";
    
   return new Promise(() => {
        pyccselect(code).then(res => {
          this.pyccList = res.data.data[0].children 
         console.log(res.data.data[0].children,"pyccselect")
        });
      });
  },
    selectPro() {
      this.ruleForm.id = this.$route.query.rowins.id;
      this.ruleForm.zymc = this.$route.query.rowins.name;
      this.ruleForm.zyjc = this.$route.query.rowins.simpleName;
      this.ruleForm.yndm = this.$route.query.rowins.collegeCode;
      this.pycc = this.$route.query.rowins.trainingleveid+','+this.$route.query.rowins.trainingLevel;
      this.cdyq = this.$route.query.rowins.undertakeCollege;
      this.ruleForm.bzdm = this.$route.query.rowins.standardCode;
      this.ruleForm.ywmc = this.$route.query.rowins.englishName;
      this.ruleForm.zyjs = this.$route.query.rowins.introduction;
      this.ruleForm.jlny = this.$route.query.rowins.establishTime;
      this.ruleForm.pzwh = this.$route.query.rowins.approvalNumber;
      this.bzxz = this.$route.query.rowins.standardEduSystem;
      this.sqxw.push(this.$route.query.rowins.grantDegree);
      this.xkml = this.$route.query.rowins.subjectType;
    },
    handleCheckedCitiesChange(value) {
      if(value.length>1){
        let one = value.splice(1)
        this.sqxw = one
      }
    },
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          let obj = {
            id: this.ruleForm.id,
            name: this.ruleForm.zymc,
            simpleName: this.ruleForm.zyjc,
            collegeCode: this.ruleForm.yndm,
            standardCode: this.ruleForm.bzdm,
            introduction: this.ruleForm.zyjs,
            trainingleveid:  this.pycc.split(',')[0],
            trainingLevel: this.pycc.split(',')[1],
            establishTime: this.ruleForm.jlny,
            englishName: this.ruleForm.ywmc,
            undertakeCollege: this.cdyq,
            approvalNumber: this.ruleForm.pzwh,
            standardEduSystem: this.bzxz,
            subjectType: this.xkml,
            grantDegree: this.sqxw[0]
          };
          console.log(obj,"000")
          let rowindex = {
           school: this.cdyq,
        id: this.pycc.split(',')[0]
          };
          slePro(obj).then(res => {
            if(res.data.code == 200){
              this.$message({ type: "success", message: "保存成功！" });
              this.$router.push({path:"/admin/professional/details", query: { rowindex: rowindex }});
            }
          });
        } else {
          console.log("error submit!!");
          return false;
        }
      });

    },
    resetForm() {
     
      let rowindex = {
        school: this.cdyq,
        id: this.pycc.split(',')[0]
      };
      this.$router.push({
        path: "/admin/professional/details",
        query: { rowindex: rowindex }
      });
    },

    // submitForm(formName) {
    //   this.$refs[formName].validate(valid => {
    //     if (valid) {
    //       alert("submit!");
    //     } else {
    //       console.log("error submit!!");
    //       return false;
    //     }
    //   });
    // },
    // resetForm(formName) {
    //   this.$refs[formName].resetFields();
    // },

    baoc() {
      let obj = {
        name: this.tablelist.zymc,
        simpleName: this.tablelist.zyjc,
        undertakeCollege: this.tablelist.cdyx,
        trainingLevel: this.tablelist.pycc,
        collegeCode: this.tablelist.yndm,
        standardCode: this.tablelist.bzdm,
        englishName: this.tablelist.ywmc,
        subjectType: this.tablelist.xkml,
        grantDegree: this.tablelist.sqxw,
        standardEduSystem: this.tablelist.bzxz,
        approvalNumber: this.tablelist.pzwh,
        establishTime: this.tablelist.jlny,
        introduction: this.tablelist.zyjs
      };
      tjzy(obj).then(res => {});
    },
    qux() {}
  }
};
</script>
<style lang="less" scoped>
.el-form-item--mini.el-form-item,
.el-form-item--small.el-form-item,
.el-form-item {
  margin-bottom: 0px;
}
.zyjs {
  width: 78.5%;
  margin: 20px auto;
  // margin-left: 2.5% !important;
  /deep/ .el-input__inner {
    height: 80px !important;
  }
}
.el-input {
  width: 500px;
  display: flex;
  justify-items: center;
  align-items: center;
  margin-left: 40px;
  margin-right: 40px;
}
.my-form-item {
  height: 80px;
}
.el-select {
  width: 500px;
  display: flex;
  justify-items: center;
  align-items: center;
  margin-left: 40px;
  margin-right: 40px;
}
.el-date-editor {
  width: 500px;
  display: flex;
  justify-items: center;
  align-items: center;
  margin-left: 40px;
  margin-right: 40px;
}
.choose-ypr-container {
  width: 100%;
  margin: 0px auto;

  .choose-ypr-search-container {
    .el-input--prefix .el-input__inner {
      padding-left: 30px;
    }

    .el-input__inner {
      &::placeholder {
        color: #b8b8b8;
      }

      &::-webkit-input-placeholder {
        /* WebKit browsers 适配谷歌 */
        color: #b8b8b8;
      }

      &:-moz-placeholder {
        /* Mozilla Firefox 4 to 18 适配火狐 */
        color: #b8b8b8;
      }

      &::-moz-placeholder {
        /* Mozilla Firefox 19+ 适配火狐 */
        color: #b8b8b8;
      }

      &:-ms-input-placeholder {
        /* Internet Explorer 10+  适配ie*/
        color: #b8b8b8;
      }
    }

    display: flex;
    flex-direction: row;
    align-items: center;

    .title {
      font-size: 18px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      line-height: 20px;
      color: #004ca7;
      margin-right: 5px;
    }

    .search-button {
      width: 77px;
      height: 28px;
      line-height: 28px;
      background: #f1f8fe;
      border: 1px solid #51aef6;
      border-radius: 6px;
      cursor: pointer;
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: center;

      > span {
        font-size: 16px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #51aef6;
      }

      > img {
        width: 20px;
        height: 20px;
        margin-right: 4px;
      }
    }

    .button-list {
      display: flex;
      flex-direction: row;
      align-items: center;
      margin-left: 21px;

      .button-item {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: center;
        position: relative;
        width: 69px;
        height: 27px;
        line-height: 27px;
        border: 1px solid #004ca7;
        border-radius: 4px;
        margin-right: 10px;
        text-align: center;
        font-size: 14px;
        font-family: Microsoft YaHei;
        font-weight: 400;
        color: #004ca7;

        .del-icon {
          position: absolute;
          right: 0px;
          top: 0px;
          width: 12px;
          height: 12px;
          padding: 2px;
        }
      }
    }
  }

  .choose-ypr-container .choose-ypr-table-container .el-table__header th {
    padding: 0;
    height: 57px;
    background-color: #edf2f9;
    font-size: 16px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    line-height: 20px;
    color: #004ca7;
  }

  /deep/ .el-table .cell {
    color: #004ca7;
  }

  .choose-ypr-table-container {
    margin-top: 30px;

    .el-table td,
    .el-table th.is-leaf,
    .el-table--border,
    .el-table--group {
      border-color: #c7d7eb;
    }

    .el-table__header tr,
    .el-table__header th {
      padding: 0;
      height: 57px;
      background-color: #edf2f9;
      font-size: 16px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      line-height: 20px;
      color: #004ca7;
    }

    .el-table__body tr,
    .el-table__body td {
      padding: 0;
      height: 51px;
    }

    .table-data {
      width: 100%;
      border: 0.8px solid #004ca7;
      border-radius: 9px;
      font-size: 14px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #004ca7;
    }
  }
}

.assessment-container {
  .el-dialog__body {
    height: 251px;
  }

  .el-dialog__footer {
    padding: 10px 20px 45px;
  }

  .el-checkbox__inner:hover {
    border-color: #004ca7;
  }

  .el-checkbox__inner {
    border: 1px solid #004ca7;
    border-radius: 0;
    height: 18px;
    width: 18px;
  }

  .el-checkbox__inner::after {
    height: 10px;
    left: 6px;
  }

  .el-checkbox__input.is-checked .el-checkbox__inner,
  .el-checkbox__input.is-indeterminate .el-checkbox__inner {
    background-color: #004ca7;
    border-color: #004ca7;
  }

  .el-checkbox__input.is-checked + .el-checkbox__label {
    color: #004ca7;
  }

  .el-checkbox.is-bordered.is-checked {
    border-color: #004ca7;
  }

  .el-checkbox__input.is-focus .el-checkbox__inner {
    border-color: #004ca7;
  }
}

.cz-save {
  box-sizing: border-box;
  line-height: 44px;
  border-radius: 4px;
  font-size: 12px;
  font-family: Microsoft YaHei;
  font-weight: 400;
  text-align: center;
  margin-top: 70px;
  margin-left: 40px;
  display: flex;
  flex-direction: row;
  cursor: pointer;
  align-content: center;
  justify-content: center;
  align-items: center;
}

.jf-save {
  display: flex;
  align-items: center;
  margin-left: 48px;
}

.fileClass {
  position: relative;
  cursor: pointer;

  .save {
    width: 120px;
    height: 50px;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    color: #fff;
    background: #303133;
  }
}

.my-form-item-value {
  font-size: 16px;
  color: #004ca7;
  height: 100%;
  flex: 1;
  line-height: 60px;
  padding-left: 38px;
  display: flex;
  align-items: center;
}

.assessment-edit-plan-container {
  .assessment-design {
    .el-textarea__inner {
      resize: none;
      font-size: 16px;
      color: rgba(0, 76, 167, 1);
    }
  }
}
</style>
<style scoped lang="less">
/deep/ .el-form-item__error {
  color: #f56c6c;
  font-size: 12px;
  line-height: 1;
  padding-top: 5px;
  position: absolute;
  top: 75%;
  left: 320px;
}
.assessment-edit-plan-container {
  .assessment-design {
    padding: 25px 38px !important;
  }

  .button-group {
    margin-top: 50px;
    text-align: center;

    > div {
      display: inline-block;
      font-size: 18px;
      padding: 6px 22px;
      border-radius: 6px;

      &:nth-child(1) {
        color: #f3b815;
        border: 1px solid #f3b815;
        background: #fff6ef;
        margin-right: 139px;
      }

      &:nth-child(2) {
        color: #ff3819;
        border: 1px solid #ff3819;
        background: #ffefef;
      }
    }
  }
}
</style>
